package com.powernode.business.controller;

import com.powernode.business.domain.Check;
import com.powernode.business.service.CheckService;
import com.powernode.common.core.controller.BaseController;
import com.powernode.common.core.domain.AjaxResult;
import com.powernode.common.core.domain.model.LoginUser;
import com.powernode.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("business/check")
@Api(tags = "检查单管理")
public class CheckController extends BaseController {

    @Autowired
    private CheckService checkService;

    @GetMapping("list")
    @ApiOperation("分页查询检查单")
    public TableDataInfo list(Check check){
        startPage();
        LoginUser loginUser = getLoginUser();
        List<Check> checkList = checkService.selectcrCheck(check,loginUser);
        return getDataTable(checkList);
    }

    @DeleteMapping("{id}")
    @ApiOperation("删除检查单")
    public AjaxResult deleteCheck(@PathVariable("id") List<Integer> id){
        LoginUser loginUser = getLoginUser();
        return toAjax(checkService.deleteCheck(id,loginUser.getUsername()));
    }

}
